package com.tanzeer.deliverytracker;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class AboutActivity extends Activity {
	ActionBar actionBar;
	TextView txtNotNow;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_about);
		actionBar = getActionBar();
		actionBar.setTitle("About");
		actionBar.setDisplayHomeAsUpEnabled(true);
		txtNotNow = (TextView) findViewById(R.id.textView5);
		txtNotNow.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				moveBack();

			}
		});
	}

	@Override
	protected void onStart() {
		overridePendingTransition(R.anim.anim_in, R.anim.anim_out);
		super.onStart();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		// getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if (item.getItemId() == android.R.id.home) {
			moveBack();
			return true;
		}

		return super.onOptionsItemSelected(item);
	}

	private void moveBack() {
		Intent intent = getIntent();
		int x = intent.getIntExtra("activity", -1);
		// x==0 means it started from main activity and else it is from
		// DeliveryListActivity
		if (x == 0) {
			Intent intentHome = new Intent(getApplicationContext(),
					MainActivity.class);
			intentHome.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(intentHome);
			overridePendingTransition(R.anim.anim_in_left, R.anim.anim_out_left);
		}

		else {
			Intent intentHome = new Intent(getApplicationContext(),
					DeliveryListActivity.class);
			intentHome.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			intentHome.putExtra("type",
					getIntent().getStringExtra("contenttype"));
			intentHome.putExtra("value", 1);
			startActivity(intentHome);
			overridePendingTransition(R.anim.anim_in_left, R.anim.anim_out_left);

		}

	}

	@Override
	public void onBackPressed() {

		moveBack();

	}
}
